﻿using System;
using CommonExtensions.ObjectExtensions;
using CommonExtensions.StringExtensions;

namespace DBMigrator.Core.DbObjects.Data.Update.Set
{
    public abstract class BaseSet : IBaseSet
    {
        public string ColumnName { get; private set; }
        public object Value { get; private set; }
        public IAdditionalSet AdditionalSet { get; private set; }

        public BaseSet(IAdditionalSet additionalSet)
        {
            if(additionalSet.IsNull())
                throw new ArgumentNullException("additionalSet");

            AdditionalSet = additionalSet;
        }
        
        protected IAdditionalSet SetColumnTo<T>(string columnName, T value)
        {
            if(columnName.IsBlank())
                throw new ArgumentNullException();

            ColumnName = columnName;
            Value = value;

            return AdditionalSet;
        }
    }
}